<template>
    <div>
       <!-- 优惠券单元格 -->
       <header>
         <i style="color:white" @click="back" class="iconfont">&#xe663;</i>
         <p style="color:white;">优惠卷</p>
         
     </header>
<van-coupon-cell
  :coupons="coupons"
  :chosen-coupon="chosenCoupon"
  @click="showList = true"
/>
<!-- 优惠券列表 -->
<van-popup
  v-model="showList"
  round
  position="bottom"
  style="height: 90%; padding-top: 4px;"
>
  <van-coupon-list
    :coupons="coupons"
    :chosen-coupon="chosenCoupon"
    :disabled-coupons="disabledCoupons"
    @change="onChange"
    @exchange="onExchange"
  />
</van-popup>
    </div>
</template>

<script>
const coupon = {
  available: 1,
  condition: '无使用门槛\n最多优惠12元',
  reason: '',
  value: 150,
  name: '优惠券名称',
  startAt: 1489104000,
  endAt: 1514592000,
  valueDesc: '1.5',
  unitDesc: '元',
};
export default {
    name: '',
     data() {
    return {
      chosenCoupon: -1,
      coupons: [coupon],
      disabledCoupons: [coupon],
      showList:''
    }
  },
  methods: {
    onChange(index) {
      this.showList = false;
      this.chosenCoupon = index;
    },
    onExchange(code) {
      this.coupons.push(coupon);
    },
    back(){
        this.$router.go(-1)
    }
  },
}
</script>

<style scoped>
header{
    position: relative;
    width: 100vw;
    padding: 2vh 0;
    text-align: center;
    background-image: linear-gradient(to right top,rgba(193, 218, 82, 0.884),rgb(174, 0, 255),blue);
}
header>i{
  position: absolute;
  left: 5vw;
}
</style>